package com.作业.Day7;

public class Homework2 {
    public static void main(String[] args) {
        MotosVehile[] motos = new MotosVehile[4];
        motos[0]=   new Car("宝马","京9999");
        motos[1]= new Car("别克林","nihao");
        motos[2]= new Car("宝马","nihao");
        motos[3]= new Bus("金龙",34);
        int i = calcTotalRent(motos, 5);
        System.out.println(i);
    }
    static int calcTotalRent(MotosVehile[] motos,int days){
        int totalRent=0;
        for (int i = 0; i < motos.length; i++) {
            totalRent+=motos[i].calRent(days);
        }
        return totalRent;
    }


}
 abstract class MotosVehile {
    String name;
    String brand;

     public MotosVehile(String brand, String name) {
         this.brand = brand;
         this.name = name;
     }

     public MotosVehile(String name) {
         this.name = name;
     }

     public MotosVehile() {
     }

     abstract   int calRent(int days);

}
class Car extends MotosVehile {
    public Car(String name, String brand) {
        super(name, brand);
    }


    int calRent(int days){
        int sum=0;
        int a=0;
        if(this.name.equals("宝马"))
            a=600;
        else if(this.name.equals("别克林"))
            a=300;
        else
            a=150;
        for (int i = 0; i <days ; i++) {
            sum+=days*a;
        }
        return sum;
    }

}
class Bus extends MotosVehile {
    int all;
    public Bus(String name, int all) {
         super(name);
         this.all=all;
    }

    int calRent(int days){
        int sum=0;
        int a=0;
        if(this.all>16)
            a=1600;
        else
            a=800;
        for (int i = 0; i <days ; i++) {
            sum+=days*a;
        }
        return sum;
    }
}